csssection: Make printing functions public
authorBenjamin Otte <otte@redhat.com>
Wed, 10 Apr 2019 15:23:14 +0000 (17:23 +0200)
committerBenjamin Otte <otte@redhat.com>
Fri, 12 Apr 2019 17:34:28 +0000 (19:34 +0200)
docs/reference/gtk/gtk4-sections.txt
gtk/gtkcssanimatedstyle.c
gtk/gtkcssnode.c
gtk/gtkcssprovider.c
gtk/gtkcsssection.c
gtk/gtkcsssection.h
gtk/gtkcsssectionprivate.h [deleted file]
gtk/gtkcssstaticstyle.c
gtk/gtkcssstyle.c
gtk/inspector/css-node-tree.c

index 9797298262a7ef716830c2b0034574b5ccec88d8..32a1ad59f7d0acccf736d5e7e22163d29abc8aca 100644 (file)
@@ -5095,6 +5095,8 @@ GtkCssSection
 gtk_css_section_new
 gtk_css_section_ref
 gtk_css_section_unref
+gtk_css_section_print
+gtk_css_section_to_string
 gtk_css_section_get_file
 gtk_css_section_get_parent
 gtk_css_section_get_start_location
index 54dfa3684a4ce07f1fb68e7f8868742a270b215d..c09ddb01cef4a9ad54572f01d7e3ceaddc72a91a 100644 (file)
@@ -28,7 +28,6 @@
 #include "gtkcssinheritvalueprivate.h"
 #include "gtkcssinitialvalueprivate.h"
 #include "gtkcssnumbervalueprivate.h"
-#include "gtkcsssectionprivate.h"
 #include "gtkcssshorthandpropertyprivate.h"
 #include "gtkcssstaticstyleprivate.h"
 #include "gtkcssstringvalueprivate.h"
index f940c53b5d944c75d178353eec188a4da5900f43..8bcf5faa92c6999d48e840694818c715781630f3 100644 (file)
@@ -20,7 +20,6 @@
 #include "gtkcssnodeprivate.h"
 
 #include "gtkcssanimatedstyleprivate.h"
-#include "gtkcsssectionprivate.h"
 #include "gtkcssstylepropertyprivate.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
index c16bfcb94b651a8ff9e0d94160195f598861a053..8f1bb22f3dff148c2a83df9b36d3c5a2f32a5809 100644 (file)
@@ -30,7 +30,7 @@
 #include "gtkcsscolorvalueprivate.h"
 #include "gtkcsskeyframesprivate.h"
 #include "gtkcssparserprivate.h"
-#include "gtkcsssectionprivate.h"
+#include "gtkcsssection.h"
 #include "gtkcssselectorprivate.h"
 #include "gtkcssshorthandpropertyprivate.h"
 #include "gtksettingsprivate.h"
@@ -162,7 +162,7 @@ gtk_css_provider_parsing_error (GtkCssProvider  *provider,
                                      0,
                                      TRUE))
     {
-      char *s = _gtk_css_section_to_string (section);
+      char *s = gtk_css_section_to_string (section);
 
       g_warning ("Theme parsing error: %s: %s",
                  s,
index caf2b7509c2c580ad41cc8af2f672e193cb5fc6a..31346667963885e025e7f4ad93c096af710deb8e 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "config.h"
 
-#include "gtkcsssectionprivate.h"
+#include "gtkcsssection.h"
 
 #include "gtkcssparserprivate.h"
 #include "gtkprivate.h"
@@ -184,9 +184,18 @@ gtk_css_section_get_end_location (const GtkCssSection *section)
   return &section->end_location;
 }
 
+/**
+ * gtk_css_section_print:
+ * @section: a section
+ * @string: a #GString to print to
+ *
+ * Prints the @section into @string in a human-readable form. This
+ * is a form like `gtk.css:32:1-23` to denote line 32, characters
+ * 1 to 23 in the file gtk.css.
+ **/
 void
-_gtk_css_section_print (const GtkCssSection  *section,
-                        GString              *string)
+gtk_css_section_print (const GtkCssSection  *section,
+                       GString              *string)
 {
   if (section->file)
     {
@@ -210,19 +219,36 @@ _gtk_css_section_print (const GtkCssSection  *section,
     }
 
   g_string_append_printf (string, ":%zu:%zu", 
-                          section->end_location.lines + 1,
-                          section->end_location.line_chars + 1);
+                          section->start_location.lines + 1,
+                          section->start_location.line_chars + 1);
+  if (section->start_location.lines != section->end_location.lines ||
+      section->start_location.line_chars != section->end_location.line_chars)
+    {
+      g_string_append (string, "-");
+      if (section->start_location.lines != section->end_location.lines)
+        g_string_append_printf (string, "%zu:", section->end_location.lines + 1);
+      g_string_append_printf (string, "%zu", section->end_location.line_chars + 1);
+    }
 }
 
+/**
+ * gtk_css_section_to_string:
+ * @section: a #GtkCssSection
+ *
+ * Prints the section into a human-readable text form using
+ * gtk_css_section_print().
+ *
+ * Returns: (transfer full): A new string.
+ **/
 char *
-_gtk_css_section_to_string (const GtkCssSection *section)
+gtk_css_section_to_string (const GtkCssSection *section)
 {
   GString *string;
 
   gtk_internal_return_val_if_fail (section != NULL, NULL);
 
   string = g_string_new (NULL);
-  _gtk_css_section_print (section, string);
+  gtk_css_section_print (section, string);
 
   return g_string_free (string, FALSE);
 }
index 1fd56eab3f6e769e33175fc32b4683b7129b00c8..fbca82105b6e8e789176a6d5c98bedd29d4077a6 100644 (file)
@@ -46,6 +46,12 @@ GtkCssSection *    gtk_css_section_ref                 (GtkCssSection        *se
 GDK_AVAILABLE_IN_ALL
 void               gtk_css_section_unref               (GtkCssSection        *section);
 
+GDK_AVAILABLE_IN_ALL
+void               gtk_css_section_print               (const GtkCssSection  *section,
+                                                        GString              *string);
+GDK_AVAILABLE_IN_ALL
+char *             gtk_css_section_to_string           (const GtkCssSection  *section);
+
 GDK_AVAILABLE_IN_ALL
 GtkCssSection *    gtk_css_section_get_parent          (const GtkCssSection  *section);
 GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkcsssectionprivate.h b/gtk/gtkcsssectionprivate.h
deleted file mode 100644 (file)
index 863ee2b..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2011 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_CSS_SECTION_PRIVATE_H__
-#define __GTK_CSS_SECTION_PRIVATE_H__
-
-#include "gtkcsssection.h"
-
-#include "gtkcssparserprivate.h"
-
-G_BEGIN_DECLS
-
-void               _gtk_css_section_print              (const GtkCssSection  *section,
-                                                        GString              *string);
-char *             _gtk_css_section_to_string          (const GtkCssSection  *section);
-
-G_END_DECLS
-
-#endif /* __GTK_CSS_SECTION_PRIVATE_H__ */
index e257296fd0bf8011a418d35b2aaee96dfd1b0b63..d0557597a3fd981f77ec44ed8dd23de97fd106a7 100644 (file)
@@ -27,7 +27,6 @@
 #include "gtkcssinheritvalueprivate.h"
 #include "gtkcssinitialvalueprivate.h"
 #include "gtkcssnumbervalueprivate.h"
-#include "gtkcsssectionprivate.h"
 #include "gtkcssshorthandpropertyprivate.h"
 #include "gtkcssstringvalueprivate.h"
 #include "gtkcssstylepropertyprivate.h"
index d896aebed3cff26fbe803a5be23547cf9f5375ee..89f4a102a1306f8d699273a3e43b4a14d5c6b5bd 100644 (file)
@@ -29,7 +29,7 @@
 #include "gtkcssinitialvalueprivate.h"
 #include "gtkcssnumbervalueprivate.h"
 #include "gtkcssrgbavalueprivate.h"
-#include "gtkcsssectionprivate.h"
+#include "gtkcsssection.h"
 #include "gtkcssshorthandpropertyprivate.h"
 #include "gtkcssstringvalueprivate.h"
 #include "gtkcssfontfeaturesvalueprivate.h"
@@ -162,7 +162,7 @@ gtk_css_style_print (GtkCssStyle *style,
       if (section)
         {
           g_string_append (string, " /* ");
-          _gtk_css_section_print (section, string);
+          gtk_css_section_print (section, string);
           g_string_append (string, " */");
         }
 
index 6093c81d5f43fb5c33a00597652a3f522983e8f8..a6d6a202bcc5bf2f90304627626abde62a839000 100644 (file)
@@ -33,7 +33,7 @@
 #include "gtk/gtkwidgetprivate.h"
 #include "gtkcssproviderprivate.h"
 #include "gtkcssstylepropertyprivate.h"
-#include "gtkcsssectionprivate.h"
+#include "gtkcsssection.h"
 #include "gtkcssstyleprivate.h"
 #include "gtkcssvalueprivate.h"
 #include "gtkcssselectorprivate.h"
@@ -473,7 +473,7 @@ gtk_inspector_css_node_tree_update_style (GtkInspectorCssNodeTree *cnt,
 
           section = gtk_css_style_get_section (new_style, i);
           if (section)
-            location = _gtk_css_section_to_string (section);
+            location = gtk_css_section_to_string (section);
           else
             location = NULL;
         }